
/* 提示 */
function tips(msg){
    layer.msg(msg);
}
function alert(msg){
    layer.alert(msg);
}
function alert(msg, options){
    layer.alert(msg, options);
}

/* 确认 */
function confirm(msg, success_fun){
     layer.confirm(msg, {
        btn: ['确认','取消']
     }, function(){
        if(success_fun != undefined){
            success_fun();
        }else{
            layer.msg("回调函数加载异常！请检查！", {icon:5});
        }
    });
}

/* 确认链接跳转 */
function confirmRedirect(msg,url){
    layer.confirm(msg, {
        btn: ['确认','取消']
    }, function(){
        window.location.href=url;
    });
}

/* 直接提交数据 */
function submitData(params, url, success_fun){
    $.ajax({
        url : url,
        dataType:'json',
        type : 'POST',
        cache: false,
        data :params,
        traditional: true, 
        success: function(data) {
            if(data!=null){
                if(data.code == 0){
                    alert(data.msg, {icon:1});
                    setTimeout(function () {
                        if(success_fun != undefined){
                            success_fun();
                        } else {
                            window.location.reload();
                        }
                    }, 1500);
                }else{
                    alert(data.msg, {icon:0});
                }
            }
        },
        error: function(XmlHttpRequest,textStatus, errorThrown){
           alert(XmlHttpRequest.responseText, {icon:2});
        }
    });
}

/* 确认提交数据 */
function confirmSubmit(msg, params, url, success_fun){
    layer.confirm(msg, {
        btn: ['确认','取消']
    }, function(){
        $.ajax({
            url : url,
            dataType:'json',
            type : 'POST',
            cache: false,
            data :params,
            traditional: true,
            success: function(data) {
                if(data!=null){
                    if(data.code == 0){
                        alert(data.msg, {icon:1});
                        setTimeout(function () {
                            if(success_fun != undefined){
                                success_fun();
                            } else {
                                window.location.reload();
                            }
                        }, 1500);
                    }else{
                        alert(data.msg, {icon:0});
                    }
                }
            },
            error: function(XmlHttpRequest,textStatus, errorThrown){
                alert(XmlHttpRequest.responseText, {icon:2});
            }
        });
    });
}
